home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / -archivi / -recent2 / amicad_2.00.lha / AmiCAD / ARexx / Cartouche.amiCAD < prev    next >
Text File  |  1999-02-07  |  4KB  |  160 lines

  1. /* Script ARexx permettant le tracé d'un cartouche dans une fenêtre AmiCAD */
  2. /* Chez Corbin, Vendredi 3 Octobre 1997, Version 1.00, © R.Florac */
  3. /* Version 1.01, 2 Novembre 1997, trait vertical rajouté dans cartouche */
  4. /* Version 1.02, 23 janvier 1998, ajout titre, date, etc... */
  5. /* Version 1.03, 12 février 1998, test longueurs chaînes pour ajustement largeur */
  6. /* Version 1.04, 24 mai 1998, test présence rexxlocaldates.library */
  7. /* Version 1.05, 21 juin 1998, ajout test après choix emplacement cartouche pour arrêt */
  8. /* Version 1.06, 14 juillet 1998, modification tracé lignes (lignes quelconques) */
  9. /* Version 1.06a, 15 janvier 1999, remplacement fonction ASK par ASKTEXT */
  10. /* $VER: Cartouche.AmiCAD 1.06a (© R.Florac, 15/01/99) */
  11.  
  12. options results
  13.  
  14. organisation="LYCÉE Bernard PALISSY SAINTES"
  15. signal on error
  16. signal on syntax
  17.  
  18. if (~show('L','rexxlocaldates.library')) then
  19.   call addlib('rexxlocaldates.library',0,-30,0)
  20.  
  21. if (show('L','rexxlocaldates.library')) then do
  22.     Ib = OpenLocale()
  23.     jour = FormatDate(Ib, ,"%A %e %B %Y")
  24. end
  25. else do
  26.     'DATE(1)'; jour=result
  27. end
  28.  
  29. 'WWIDTH(-1)'; l = result; lc = result % 3
  30. 'WHEIGHT(-1)'; h =result
  31. 'ROTATE(0,0):SYMMETRY(0,0)'
  32.  
  33. 'SELECT("Emplacement du cartouche"+CHR(10)+"En haut à gauche"+CHR(10)+"En haut à droite"+CHR(10)+"En haut au centre"+CHR(10)+"En bas au centre"+CHR(10)+"En bas à droite"+CHR(10)+"En bas à gauche")'
  34. c = result
  35. if c<1 then exit    /* Version 1.05 */
  36.  
  37. 'ASKTEXT("Titre du cartouche","")'; titre = result
  38. if titre='' then exit
  39.  
  40. if lc<260 then lc=260
  41. 'TXWIDTH("'organisation'")'; lt = result
  42. if lt>lc-10 then lc=lt+10
  43. 'TXWIDTH("'titre'")'; lt = result
  44. if lt>lc-10 then lc=lt+10
  45. dx=(lc+5)%4*3
  46. 'TXWIDTH("'jour'")'; lt = result
  47. if lt>dx-10 then do
  48.     dx=lt+10
  49.     lc=dx%3*4
  50. end
  51.  
  52. select
  53.     when c = 1 then do        /* En haut à gauche */
  54.     x0 = 5
  55.     x1 = lc + 5
  56.     y0 = 5
  57.     y1 = 85
  58.     bh = 0
  59.     bb = 1
  60.     bg = 0
  61.     bd = 1
  62.     end
  63.     when c = 2 then do        /* En haut à droite */
  64.     x0 = l - lc - 5
  65.     x1 = l - 5
  66.     y0 = 5
  67.     y1 = 85
  68.     bh = 0
  69.     bb = 1
  70.     bg = 1
  71.     bd = 0
  72.     end
  73.     when c = 3 then do        /* En haut au centre */
  74.     x0 = l % 2 - lc % 2
  75.     x1 = x0 + lc
  76.     y0 = 5
  77.     y1 = 85
  78.     bh = 0
  79.     bb = 1
  80.     bg = 1
  81.     bd = 1
  82.     end
  83.     when c = 4 then do        /* En bas au centre */
  84.     x0 = l % 2 - lc % 2
  85.     x1 = x0 + lc
  86.     y0 = h - 85
  87.     y1 = h - 5
  88.     bh = 1
  89.     bb = 0
  90.     bg = 1
  91.     bd = 1
  92.     end
  93.     when c = 6 then do        /* En bas à gauche */
  94.     x0 = 5
  95.     x1 = 5 + lc
  96.     y0 = h - 85
  97.     y1 = h - 5
  98.     bh = 1
  99.     bb = 0
  100.     bg = 0
  101.     bd = 1
  102.     end
  103.     when c = 5 then do        /* En bas à droite */
  104.     x0 = l - lc - 5
  105.     x1 = l - 5
  106.     y0 = h - 85
  107.     y1 = h - 5
  108.     bh = 1
  109.     bb = 0
  110.     bg = 1
  111.     bd = 0
  112.     end
  113.     otherwise exit
  114. end
  115.  
  116. /* sauvegarde du contexte, dessin du contour */
  117. 'SAVEALL(-1):DRAWMODE(-2):DRAW(5,5,'l-5',5):DRAW('l-5',5,'l-5','h-5')'
  118. 'DRAW('l-5','h-5',5,'h-5'):DRAW(5,'h-5',5,5)'
  119.  
  120. /* Tracé du bord horizontal haut */
  121. if bh > 0 then 'DRAW('x0','y0','x1','y0')'
  122. /* Tracé du bord horizontal bas */
  123. if bb > 0 then 'DRAW('x0','y1','x1','y1')'
  124. /* Tracé du bord vertical gauche */
  125. if bg > 0 then 'DRAW('x0','y0','x0','y1')'
  126. /* Tracé du bord vertical droit */
  127. if bd > 0 then 'DRAW('x1','y0','x1','y1')'
  128. /* Tracé des lignes horizontales intermédiaires */
  129. 'DRAW('x0','y0+20','x1','y0+20')'
  130. 'DRAWMODE(-1):DRAW('x0','y0+40','x1','y0+40'):DRAW('x0','y0+60','x1','y0+60')'
  131. /* Tracé de la ligne verticale intermédiaire */
  132. 'DRAW('dx+x0','y0+40','dx+x0','y1')'
  133.  
  134. 'SETSCALE(0,100,100)'
  135. call centrer_texte(organisation,x0,x1,y0+15)
  136. call centrer_texte(titre,x0,x1,y0+35)
  137. call centrer_texte(jour,x0,x0+dx,y0+75)
  138. call centrer_texte("Document Numéro 1/1",x0,x0+dx,y0+55)
  139. call centrer_texte("REV 1",x0+dx,x1,y0+55)
  140. call centrer_texte("AmiCAD",x0+dx,x1,y0+75)
  141.  
  142. exit
  143.  
  144. centrer_texte: procedure
  145.     parse arg texte, xg, xd, y
  146.     'TXWIDTH("'texte'")'; l = result
  147.     l = (xd-xg-l)%2
  148.     'WRITE("'texte'",'xg+l','y')'
  149.     return
  150.  
  151. /* Traitement des erreurs, interruption du programme */
  152. syntax:
  153. erreur=RC
  154. 'MESSAGE("Script Cartouche.AmiCAD:"+CHR(10)+"Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  155. exit
  156.  
  157. error:
  158. 'MESSAGE("Script Cartouche.AmiCAD:"+CHR(10)+"Erreur en ligne 'SIGL'")'
  159. exit
  160.